;
(function() {
	var historyMap = {};
	module.exports = {
		save: function() {
			db.update(db_table_name, this._id, this);
		},
		destroy: function() {
			db.remove(db_table_name, this._id);
		},
		/*
		 * history_info
		 * + time_at
		 * + flag
		 */
		addHistory: function(history_info) {
			var flag = history_info.flag;
			if (!flag) {
				throwCusError("访问标识不可为空");
			}

			var time_at = +history_info.time_at;
			if (!time_at) {
				time_at = +new Date;
			}

			var map = historyMap[this._id] || (historyMap[this._id] = {});
			if (map.hasOwnProperty(flag)) {
				return
			} else {
				this.history_list.push({
					time_at: time_at,
					flag: flag
				});
				map[flag] = time_at;
				setTimeout(function() {
					delete map[flag];
				}, config.hotDelay);

				this.save();
			}
		}
	};
	var db = require("../db/index");
	var config = require("../_include/config");
	var db_table_name = config.dbname.hot;
	var db_id_prefix = config.dbIdPrefix.hot;
}());